package com.springboot.test.controller;

import com.springboot.test.properties.UserProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

/**
 * Created by Kang on 2017/8/12.
 */
@RestController
@RequestMapping(value = "kang")
public class HelloController {
    @Autowired
    private UserProperties userProperties;

    @Value("${home}")
    private String home;

    @Value("${content}")
    private String content;

    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    private String hello() {
        return content;
    }

    //    http://localhost:8080/hello/say/50
    @RequestMapping(value = "/say/{id}", method = RequestMethod.GET)
    private String say(@PathVariable(value = "id") Integer id) {
        return "say, id: " + id;
    }

    //    http://localhost:8080/hello/say?id=100
    @RequestMapping(value = "/say", method = RequestMethod.GET)
    private String hi(@RequestParam(value = "id", required = false, defaultValue = "100") Integer myId) {
        return "hi, id: " + myId;
    }
}
